using System;
using AndyPike.Snowflake.Core.Mappers;
using AndyPike.Snowflake.Core.Messages;
using AndyPike.Snowflake.Entities;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace AndyPike.Snowflake.Core.Tests.Unit.Mappers
{
    [TestFixture]
    public class When_mapping_an_account_to_an_account_info_message
    {
        private AccountToAccountInfoMessageMapper mapper;

        [SetUp]
        public void SetUp()
        {
            mapper = new AccountToAccountInfoMessageMapper();
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Should_throw_an_exception_if_the_message_is_null()
        {
            mapper.Map(null);
        }

        [Test]
        public void Should_map_successfully_given_a_valid_message()
        {
            AccountInfoMessage message = mapper.Map(new Account { UserName = "andypike", Email = "someone@somewhere.com" });

            Assert.That(message.UserName, Is.EqualTo("andypike"));
            Assert.That(message.Email, Is.EqualTo("someone@somewhere.com"));
        }
    }
}